home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 5 / 005.d81 / sound designer (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  26KB  |  800 lines

  1. 10 rem sound generator
  2. 12 print"[147][144]":poke53280,4:poke53281,1
  3. 13 gosub51000
  4. 15 dimoo$(1):oo$(0)="off":oo$(1)="on"
  5. 20 dima%(2),d%(2),s%(2),r%(2),ad%(2),sr%(2),p1%(2),p2%(2)
  6. 30 dimt1%(2),t2%(2),wf%(2),pw%(2)
  7. 50 forl=54272to54296:pokel,0:next
  8. 55 forv=0to2
  9. 57 tr%(v)=0:st%(v)=0:pu%(v)=1:no%(v)=0:rm%(v)=0:sy%(v)=0:te%(v)=0
  10. 60 a%(v)=8:d%(v)=8:s%(v)=8:r%(v)=8:ad%(v)=136:sr%(v)=136
  11. 70 p1%(v)=8:p2%(v)=0:t1%(v)=32:t2%(v)=128
  12. 75 wf%(v)=64:pw%(v)=256*p1%(v)+p2%(v)
  13. 85 poke54277+7*v,ad%(v):poke54278+7*v,sr%(v):poke54276+7*v,wf%(v)
  14. 90 poke54275+7*v,p1%(v):poke54274+7*v,p2%(v):poke54273+7*v,t1%(v)
  15. 92 poke54272+7*v,t2%(v):next
  16. 95 v%=15:vn%=0:poke54296,v%
  17. 97 cf%=0:re%=0:f1%=0:f2%=0:f3%=0:lp%=0:bp%=0:hp%=0:o3%=0:ef%=0
  18. 100 rem start
  19. 110 m%=1
  20. 115 ht=8
  21. 117 pi%=16
  22. 120 print"[147][144]":poke53280,4:poke53281,1
  23. 125 print"[156][157][157][157][157][157][157][157][157][157][157][157][157][198]=[198]ilter[157][157][157][157][157][157][157][157][205]=[205]isc.[157][157][157][157][157][157][157][210][197][212][213][210][206]=[197]xit";
  24. 127 print"[157][157][157][157][157][157][157][157][157][157][157]?=[201]nfo[144]"
  25. 130 printtab(ht-2)"[195]-64 [211]ound [199]enerator[144]"
  26. 140 print:printtab(ht)"[195]oarse [212]une:"t1%(vn%)
  27. 150 print:printtab(ht)"[198]ine [212]une:"t2%(vn%)
  28. 160 print:printtab(ht)"[193]ttack:"a%(vn%)
  29. 170 print:printtab(ht)"[196]ecay:"d%(vn%)
  30. 180 print:printtab(ht)"[211]ustain:"s%(vn%)
  31. 190 print:printtab(ht)"[210]elease:"r%(vn%)
  32. 200 print:printtab(ht)"[215]aveform:"2*int(wf%(vn%)/2)
  33. 210 print:printtab(ht)"[208]ulse [215]idth:"pw%(vn%)
  34. 220 print:printtab(ht)"[214]olume:"v%
  35. 230 print:printtab(ht+3)"[211]ound ";:ifwf%(vn%)/2=int(wf%(vn%)/2)thenprint"off"
  36. 232 ifwf%(vn%)/2<>int(wf%(vn%)/2)thenprint"on"
  37. 235 print:printtab(ht)"[214]oice:"vn%+1"[144]"
  38. 240 gosub5000
  39. 250 gosub1000
  40. 255 ifrd=1then120
  41. 260 geti$
  42. 265 ifval(i$)>0andval(i$)<4thenvn%=val(i$)-1:goto120
  43. 266 ifi$="[198]"ori$="f"thengosub30000:goto120
  44. 267 ifi$=chr$(13)then500
  45. 268 ifi$="[205]"ori$="m"thengosub36000:goto120
  46. 269 ifi$="?"ori$="/"thengosub40000:goto120
  47. 270 ifi$<>""thengosub1500
  48. 300 goto250
  49. 350 a$=mid$(str$(a),2):return
  50. 360 nl=0:print"[200]it any key to continue."
  51. 370 geti$:ifi$=""then370
  52. 380 print"[147]":return
  53. 400 printleft$("",v)spc(h-1):return
  54. 450 rem print program line
  55. 452 ifpr=0thennl=nl+1:ifnl>10thengosub360
  56. 455 a=ln:gosub350:print#1,a$" ";
  57. 457 ifl1<0then480
  58. 460 print#1,"poke";:a=l1:gosub350:print#1,a$",";
  59. 465 a=v1:gosub350:print#1,a$":";
  60. 470 ifl2>=0thena=l2:gosub350:print#1,"poke"a$",";:a=v2:gosub350:print#1,a$":";
  61. 480 print#1,"rem "r$:ln=ln+li:return
  62. 500 rem end
  63. 505 print"[147]":input"[209]uit now";i$:ifleft$(i$,1)<>"[217]"andleft$(i$,1)<>"y"then120
  64. 510 forl=54272to54296:pokel,0:next
  65. 520 print:input"[211]ee pokes to make sound";i$
  66. 530 ifleft$(i$,1)="[206]"orleft$(i$,1)="n"then900
  67. 532 print:print"[207]utput to ([211])creen, ([208])rinter, or":input"([212])ext file";i$:i$=left$(i$,1)
  68. 533 pr=-1:ifi$="[208]"ori$="p"thenpr=1
  69. 534 ifi$="[212]"ori$="t"thenpr=2:gosub1900
  70. 535 ifi$="[211]"ori$="s"thenpr=0
  71. 536 ifpr=-1then532
  72. 537 ifpr=1thenopen1,4,7
  73. 538 ifpr=0thenopen1,3,7
  74. 539 print"[147]"
  75. 555 nl=0
  76. 560 print#1,"10 rem clear sound chip"
  77. 570 print#1,"20 forl=54272to54296:pokel,0:next"
  78. 580 print#1,"30 rem set up registers for sound"
  79. 585 ln=40:li=10
  80. 590 l1=54296:v1=v%+16*lp%+32*bp%+64*hp%+128*o3%:r$="mode/vol":l2=-1:gosub450
  81. 610 iff1%+f2%+f3%+ef%>0thengosub800
  82. 615 a=0:forv=0to2:ifwf%(v)/2<>int(wf%(v)/2)thena=1
  83. 617 next:ifa=0thenwf%(0)=wf%(0)+1
  84. 620 forv=0to2
  85. 622 a=v+1:ifa>2thena=0
  86. 625 if(wf%(v)/2=int(wf%(v)/2))andnot((rm%(a)=1)or(sy%(a)=1))then680
  87. 630 l1=-1:r$="voice"+str$(v+1):gosub450
  88. 640 l1=54273+7*v:v1=t1%(v):l2=54272+7*v:v2=t2%(v):r$="pitch":gosub450
  89. 650 l1=54277+7*v:v1=ad%(v):l2=54278+7*v:v2=sr%(v):r$="adsr":gosub450
  90. 660 l1=54276+7*v:v1=2*int(wf%(v)/2):l2=-1:r$="waveform":gosub450
  91. 670 ifpu%(v)thenl1=54275+7*v:v1=p1%(v):l2=54274+7*v:v2=p2%(v)
  92. 675 ifpu%(v)thenr$="pw":gosub450
  93. 680 next
  94. 690 l1=-1:r$="now start the tone!":gosub450
  95. 695 print#1,mid$(str$(ln),2)" ";
  96. 700 forv=0to2
  97. 710 ifwf%(v)/2<>int(wf%(v)/2)thena=54276+7*v:gosub350:print#1,"poke"a$",";
  98. 715 ifwf%(v)/2<>int(wf%(v)/2)thena=wf%(v):gosub350:print#1,a$":";
  99. 720 next:print#1,"rem start":ln=ln+li
  100. 730 print#1,mid$(str$(ln),2)" fora=1to800:next:rem length of tone":ln=ln+li
  101. 745 print#1,mid$(str$(ln),2)" ";
  102. 750 forv=0to2
  103. 760 ifwf%(v)/2<>int(wf%(v)/2)thena=54276+7*v:gosub350:print#1,"poke"a$",";
  104. 765 ifwf%(v)/2<>int(wf%(v)/2)thena=wf%(v)-1:gosub350:print#1,a$":";
  105. 770 next:print#1,"rem stop":ln=ln+li
  106. 772 ifpr<>2thenprint#1
  107. 775 close1
  108. 777 ifpr=2thenclose15
  109. 780 print"[200]it any key to continue."
  110. 790 geti$:ifi$=""then790
  111. 795 goto900
  112. 800 rem filter
  113. 810 l1=54295:v1=f1%+f2%*2+f3%*4+ef%*8+re%*16:l2=-1:r$="filter":gosub450
  114. 815 a=int(cf%/8):b=cf%-8*a
  115. 820 l1=54294:v1=a:l2=54293:v2=b:r$="cutoff frequency":gosub450
  116. 830 return
  117. 900 print"[147]":i$="y":input"[212]ry another sound";i$
  118. 910 ifleft$(i$,1)<>"[206]"andleft$(i$,1)<>"n"thenrun
  119. 920 print"[194]ye.":goto63000:this is for the end
  120. 1000 rem read joystick
  121. 1005 rd=0
  122. 1010 jv=peek(56320)
  123. 1020 fr=jvand16
  124. 1030 jv=15-(jvand15)
  125. 1040 if(jvand1)ori$="[145]"thengosub2000
  126. 1050 if(jvand2)ori$=""thengosub3000
  127. 1060 if(jvand4)ori$="[157]"thengosub1200
  128. 1070 if(jvand8)ori$=""thengosub1300
  129. 1080 iffr=0andbk=0thenbk=1:gosub4000
  130. 1090 iffr<>0thenbk=0
  131. 1100 return
  132. 1200 onm%gosub10000,12000,14000,16000,18000,20000,22000,24000,26000:return
  133. 1300 onm%gosub11000,13000,15000,17000,19000,21000,22000,25000,27000:return
  134. 1500 rem keyboard
  135. 1502 ifi$="0"thenh=ht+4:v=22:gosub400:print"[211]ound off"
  136. 1505 ifi$="0"thenforv=0to2:wf%(v)=2*int(wf%(v)/2):poke54276+7*v,wf%(v):next:return
  137. 1507 ifi$=" "thengosub4000
  138. 1515 ifi$<"[133]"ori$>"[140]"thenreturn
  139. 1520 ifi$="[133]"thenpi%=1
  140. 1530 ifi$="[137]"thenpi%=2
  141. 1540 ifi$="[134]"thenpi%=4
  142. 1550 ifi$="[138]"thenpi%=8
  143. 1560 ifi$="[135]"thenpi%=16
  144. 1570 ifi$="[139]"thenpi%=32
  145. 1580 ifi$="[136]"thenpi%=64
  146. 1590 ifi$="[140]"thenpi%=128
  147. 1600 return
  148. 1900 rem open textfile
  149. 1910 print:f$="":input"[198]ilename";f$
  150. 1920 iff$=""then1910
  151. 1930 open15,8,15,"s0:"+f$
  152. 1940 open1,8,1,f$+",s,w"
  153. 1950 return
  154. 2000 rem move up
  155. 2010 gosub5500
  156. 2020 m%=m%-1:ifm%=0thenm%=9
  157. 2030 gosub5000
  158. 2040 return
  159. 3000 rem move down
  160. 3010 gosub5500
  161. 3020 m%=m%+1:ifm%=10thenm%=1
  162. 3030 gosub5000
  163. 3040 return
  164. 4000 rem on/off
  165. 4010 ifwf%(vn%)/2=int(wf%(vn%)/2)then4100
  166. 4020 wf%(vn%)=wf%(vn%)-1:h=ht+4:v=22:gosub400:print"[211]ound off":goto4030
  167. 4030 poke54276+7*vn%,wf%(vn%)
  168. 4040 return
  169. 4100 wf%(vn%)=wf%(vn%)+1:h=ht+4:v=22:gosub400:print"[211]ound on ":goto4030
  170. 5000 rem plot 'cursor'
  171. 5010 v=2*m%+2:h=ht-1:gosub400:print">[144]":return
  172. 5500 rem unplot 'cursor'
  173. 5510 v=2*m%+2:h=ht-1:gosub400:print" ":return
  174. 10000 rem lower coarse tune
  175. 10010 t1%(vn%)=t1%(vn%)-1:ift1%(vn%)<0thent1%(vn%)=255
  176. 10020 poke54273+7*vn%,t1%(vn%)
  177. 10040 v=4:h=ht+13:gosub400:printt1%(vn%)"[157]  "
  178. 10050 return
  179. 11000 rem raise coarse tune
  180. 11010 t1%(vn%)=t1%(vn%)+1:ift1%(vn%)>255thent1%(vn%)=0
  181. 11020 poke54273+7*vn%,t1%(vn%)
  182. 11030 v=4:h=ht+13:gosub400:printt1%(vn%)"[157]  "
  183. 11040 return
  184. 12000 rem lower fine tune
  185. 12010 t2%(vn%)=t2%(vn%)-1:ift2%(vn%)<0thent2%(vn%)=255
  186. 12020 poke54272+7*vn%,t2%(vn%)
  187. 12030 v=6:h=ht+11:gosub400:printt2%(vn%)"[157]  "
  188. 12040 return
  189. 13000 rem raise fine tune
  190. 13010 t2%(vn%)=t2%(vn%)+1:ift2%(vn%)>255thent2%(vn%)=0
  191. 13020 poke54272+7*vn%,t2%(vn%)
  192. 13030 v=6:h=ht+11:gosub400:printt2%(vn%)"[157]  "
  193. 13040 return
  194. 14000 rem lower attack
  195. 14010 a%(vn%)=a%(vn%)-1:ifa%(vn%)<0thena%(vn%)=15
  196. 14020 ad%(vn%)=16*a%(vn%)+d%(vn%):poke54277+7*vn%,ad%(vn%)
  197. 14030 v=8:h=ht+8:gosub400:printa%(vn%)"[157]  "
  198. 14040 return
  199. 15000 rem raise attack
  200. 15010 a%(vn%)=a%(vn%)+1:ifa%(vn%)>15thena%(vn%)=0
  201. 15020 ad%(vn%)=16*a%(vn%)+d%(vn%):poke54277+7*vn%,ad%(vn%)
  202. 15030 v=8:h=ht+8:gosub400:printa%(vn%)"[157]  "
  203. 15040 return
  204. 16000 rem lower decay
  205. 16010 d%(vn%)=d%(vn%)-1:ifd%(vn%)<0thend%(vn%)=15
  206. 16020 ad%(vn%)=16*a%(vn%)+d%(vn%):poke54277+7*vn%,ad%(vn%)
  207. 16030 v=10:h=ht+7:gosub400:printd%(vn%)"[157]  "
  208. 16040 return
  209. 17000 rem raise decay
  210. 17010 d%(vn%)=d%(vn%)+1:ifd%(vn%)>15thend%(vn%)=0
  211. 17020 ad%(vn%)=16*a%(vn%)+d%(vn%):poke54277+7*vn%,ad%(vn%)
  212. 17030 v=10:h=ht+7:gosub400:printd%(vn%)"[157]  "
  213. 17040 return
  214. 18000 rem lower sustain
  215. 18010 s%(vn%)=s%(vn%)-1:ifs%(vn%)<0thens%(vn%